package org.zsl.controller;

import com.alibaba.fastjson.JSON;
import org.zsl.model.ResponseMessage;
import org.zsl.model.User;
import org.zsl.service.UserService2;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class LoginJsonController extends HttpServlet {

    private UserService2 service2=new UserService2();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {



    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


          String username = req.getParameter("username");
          String password=req.getParameter("password");
          User user = new User();
          user.setUsername(username);
          user.setPassword(password);

         ResponseMessage message= service2.login(user);

         resp.getWriter().write(JSON.toJSONString(message));

    }
}
